<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Vue中多个元素或组件过过渡</title>
	<script type="text/javascript" src="../js/vue.js"></script>
	<style type="text/css">
		.v-enter, .v-leave-to {
			opacity: 0;
		}
		.v-enter-active, .v-leave-active {
			transition: opacity 5s;
		}
	</style>
</head>
<body>
	<div id="app">
		<transition mode="out-in">
			<component :is="type"></component>
			<div v-if="show" key="hello">Hello Vue.js</div>
			<div v-else key="bye">Bye World</div>
		</transition>
		<button @click="change">转换</button>
	</div>
	<script type="text/javascript">
		Vue.component('child', {
			template: '<div>child</div>'
		})
		Vue.component('child-one', {
			template: '<div>child-one</div>'
		})
		var vm = new Vue({
			el: '#app',
			data: {
				type: 'child'
			},
			methods: {
				change: function() {
					this.type = this.type === 'child' ? 'child-one' : 'child'
				},
			}
		})
	</script>
</body>
</html>